﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace ZHello.Utils
{
    internal class VersionUtil
    {
        private static string DllVersion { get; set; }

        public static void TraceVerionInfo()
        {
            if (string.IsNullOrEmpty(DllVersion))
            {
                DllVersion = GetDllVersion();
            }
            Trace.WriteLine(string.Concat(str3: GetDllBuildDate(DllVersion).ToString("yyyy-MM-dd HH:mm:ss"), str0: "rui.tools.extensions.dll ", str1: DllVersion, str2: " BuildTime:"));
        }

        public static string GetDllVersion()
        {
            string text = DllVersion;
            if (text == null)
            {
                text = (DllVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString());
            }
            return text;
        }

        public static string GetDllVerion(Assembly ass = null)
        {
            if (ass == null)
            {
                ass = Assembly.GetExecutingAssembly();
            }
            return ass.GetName().Version.ToString();
        }

        public static DateTime GetDllBuildDate(string version)
        {
            if (string.IsNullOrEmpty(version))
            {
                return DateTime.MinValue;
            }
            string[] array = version.Split('.');
            if (array.Length != 4)
            {
                return DateTime.MinValue;
            }
            int result = 0;
            int result2 = 0;
            int.TryParse(array[2], out result);
            int.TryParse(array[3], out result2);
            return new DateTime(2000, 1, 1).AddDays(result).AddSeconds(result2 * 2);
        }
    }
}
